package com.twu.biblioteca.models;


import java.util.ArrayList;
import java.util.List;

public class BookDAO {

    private static List<Book> books = new ArrayList<Book>();

    public static final void init(){
        books.add(new Book(22, "The State of Africa", "Martin Meredith", 2006, false));
        books.add(new Book(56, "Agile & Iterative Development", "Craig Larman", 2004, false));
        books.add(new Book(73, "Agile Estimating and Planning", "Mike Cohn", 2006, false));
    }

    public List<Book> getBooksWithoutCheckout(){
        List<Book> booksWithoutCheckout = new ArrayList<Book>();

        for (Book book : books){
            if(!book.isCheckout()){
                booksWithoutCheckout.add(book);
            }
        }

        return booksWithoutCheckout;
    }

    public Book getBook(Long id){
        for (Book book : books){
            if(book.getId().equals(id)){
                return book;
            }
        }

        return null;
    }
}
